package com.atstudy.headline.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 用户留存统计表
 * @TableName user_retention_stats
 */
@TableName(value ="user_retention_stats")
@Data
public class UserRetentionStats {
    /**
     * ID
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 同期群日期(用户注册日期)
     */
    private Date cohortDate;

    /**
     * 留存天数(0表示注册当天)
     */
    private Integer dayNumber;

    /**
     * 注册用户数(day_number=0时)
     */
    private Integer userCount;

    /**
     * 留存用户数
     */
    private Integer retainedCount;

    /**
     * 留存率(%)
     */
    private BigDecimal retentionRate;

    /**
     * 创建时间
     */
    private Date createTime;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        UserRetentionStats other = (UserRetentionStats) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getCohortDate() == null ? other.getCohortDate() == null : this.getCohortDate().equals(other.getCohortDate()))
            && (this.getDayNumber() == null ? other.getDayNumber() == null : this.getDayNumber().equals(other.getDayNumber()))
            && (this.getUserCount() == null ? other.getUserCount() == null : this.getUserCount().equals(other.getUserCount()))
            && (this.getRetainedCount() == null ? other.getRetainedCount() == null : this.getRetainedCount().equals(other.getRetainedCount()))
            && (this.getRetentionRate() == null ? other.getRetentionRate() == null : this.getRetentionRate().equals(other.getRetentionRate()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getCohortDate() == null) ? 0 : getCohortDate().hashCode());
        result = prime * result + ((getDayNumber() == null) ? 0 : getDayNumber().hashCode());
        result = prime * result + ((getUserCount() == null) ? 0 : getUserCount().hashCode());
        result = prime * result + ((getRetainedCount() == null) ? 0 : getRetainedCount().hashCode());
        result = prime * result + ((getRetentionRate() == null) ? 0 : getRetentionRate().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", cohortDate=").append(cohortDate);
        sb.append(", dayNumber=").append(dayNumber);
        sb.append(", userCount=").append(userCount);
        sb.append(", retainedCount=").append(retainedCount);
        sb.append(", retentionRate=").append(retentionRate);
        sb.append(", createTime=").append(createTime);
        sb.append("]");
        return sb.toString();
    }
}
